package cn.wit.front.controller;

import cn.wit.front.service.UserService;
import cn.wit.utils.pojo.User;
import cn.wit.utils.response.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {
    @Autowired
    private UserService userService;



    @PostMapping("/updateUser")
    @ApiOperation("更新用户信息")
    public Result updateUser(@RequestBody User user) {
        return userService.updateUser(user);
    }


    @PostMapping("/selectByUserName")
    @ApiOperation("根据用户名查询")
    public Result selectByUserName(String username) {
        return userService.selectByUserName(username);
    }
    @PostMapping("/updatePwd")
    @ApiOperation("修改密码")
    public Result updatePwd(String username , String oldPassword, String newPassword) throws Exception {
        return userService.updatePwd(username, oldPassword, newPassword);
    }
}
